<tpl var layoutBody={ />
<div data-identity="sys:user" data-table="sys_user">
	<div class="layui-breadcrumb">
		<a href="/manage/index.jspx">首页</a>
		<a href="javascript:;">
			<cite>用户管理</cite>
		</a>
	</div>
	<hr>
	<form class="layui-form layui-form-pane" lay-filter="mSysUserSearchForm">
		<div class="layui-form-item layui-inline nobottom">
			<label class="layui-form-label width-auto">用户名称</label>
			<div class="layui-input-inline">
				<input type="text" name="name" placeholder="请输入用户名称" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item layui-inline nobottom">
			<label class="layui-form-label width-auto">账号/授权ID</label>
			<div class="layui-input-inline">
				<input type="text" name="account" placeholder="请输入账号/授权ID" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item layui-inline nobottom">
			<button class="layui-btn" lay-submit lay-filter="mSysUserSearchForm">查找</button>
			<a href="create.jspx" class="layui-btn layui-btn-primary">添加</a>
		</div>
	</form>
	<table class="layui-table" lay-data="{height: 'full-220', page: {hash: 'page'}, limit:30, loading:true, url:'list.json',id: 'mSysUserTable'}" lay-filter="mSysUserTableFilter">
		<thead>
			<tr>
				<th lay-data="{align: 'center', width:60, templet: '#format-avatar-tpl'}">头像</th>
				<th lay-data="{field:'name'}">用户名称</th>
				<th lay-data="{field:'account'}">用户帐号</th>
				<th lay-data="{field:'openid'}">授权ID</th>
				<th lay-data="{field:'roleName'}">用户角色</th>
				<th lay-data="{field:'createTime', width:200}">创建时间</th>
				<th lay-data="{fixed: 'right', width:140, align:'center', toolbar: '#toolbar-tpl'}"></th>
			</tr>
		</thead>
	</table>
</div>
<tpl }; />

<tpl var layoutScript={ />
<script>
	layui.config({
		base: '${webCdn}/plugins/layui/mods/'
	}).extend({
		eventbus: 'extend/eventbus/eventbus'
	}).use(['element', 'eventbus', 'table'], function () {
		// 搜索框表单提交事件
		layui.form.on('submit(mSysUserSearchForm)', function (data) {
			layui.table.reload('mSysUserTable', {
				where: data.field,
				page: {
					'curr': 1
				}
			});
			return false;
		});

		// 数据表格-工具栏-删除按钮点击事件
		layui.eventbus.table('mSysUserTableFilter', 'del', function (obj) {
			layui.layer.confirm('确定删除该用户?', function (index) {
				layui.layer.close(index);

				$.postLoading('save.json?oper=delete&id=' + obj.data.account, function (res) {
					layer.msg(res.message, {
						icon: 1,
						time: 1500
					}, function () {
						obj.del();
					});
				});
			});
		});
	});
</script>
<script type="text/html" id="format-avatar-tpl">
	<img style="height: 28px;width: 28px;border: 1px solid #eee;" src="{{d.avatar ? ('/down/thumb/' + d.avatar) : '${defAvatar}'}}">
</script>
<script type="text/html" id="toolbar-tpl">
	<div class="layui-btn-group">
		<a href="view.jspx?id={{d.account}}" class="layui-btn layui-btn-xs">查看</a>
		<a href="update.jspx?id={{d.account}}" class="layui-btn layui-btn-xs">编辑</a>
		<button type="button" class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</button>
	</div>
</script>
<tpl }; />
<tpl include( "../../tpl/layout.html",{identity: "sys:user",layoutBody:layoutBody,layoutScript:layoutScript}){}/>